package io.renren.modules.lucky.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.lucky.dao.LuckyOrderDao;
import io.renren.modules.lucky.dto.LuckyOrderDTO;
import io.renren.modules.lucky.entity.LuckyOrderEntity;
import io.renren.modules.lucky.service.LuckyOrderService;
import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 招财猫订单成功记录
 *
 * @author Liang Pei
 * @since 1.0.0 2025-01-08
 */
@Service
public class LuckyOrderServiceImpl extends CrudServiceImpl<LuckyOrderDao, LuckyOrderEntity, LuckyOrderDTO> implements LuckyOrderService {

    @Override
    public QueryWrapper<LuckyOrderEntity> getWrapper(Map<String, Object> params) {
        String id = (String) params.get("id");

        QueryWrapper<LuckyOrderEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);

        return wrapper;
    }

    @Override
    public LuckyOrderEntity queryByParam(String sessionId, String businessId, String platCode) {
        return baseDao.selectOne(new QueryWrapper<LuckyOrderEntity>()
                .eq("session_id", sessionId)
                .eq("business_id", businessId)
                .eq("plat_code", platCode));
    }
}